home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / programr / barcodes.zip / SAMPLE1.ZIP / BARDOC.CPP < prev    next >
C/C++ Source or Header  |  1994-11-07  |  4KB  |  142 lines

  1. // bardoc.cpp : implementation of the CBarDoc class
  2. //
  3.  
  4. // (c) Copyright 1994 HEX TECHNOLOGY. All rights reserved.
  5. // This sample code is provided as a example implementation
  6. // using barcodes.dll.  You may only distribute or modify this
  7. // code if you purchase a license for barcodes.dll.
  8.  
  9.  
  10. #include "stdafx.h"
  11. #include "bartest.h"
  12.  
  13. #include "bardoc.h"   
  14. #include "barcodes.h"   
  15.  
  16. #ifdef _DEBUG
  17. #undef THIS_FILE
  18. static char BASED_CODE THIS_FILE[] = __FILE__;
  19. #endif
  20.  
  21. /////////////////////////////////////////////////////////////////////////////
  22. // CBarDoc
  23.  
  24. IMPLEMENT_DYNCREATE(CBarDoc, CDocument)
  25.  
  26. BEGIN_MESSAGE_MAP(CBarDoc, CDocument)
  27.     //{{AFX_MSG_MAP(CBarDoc)
  28.         // NOTE - the ClassWizard will add and remove mapping macros here.
  29.         //    DO NOT EDIT what you see in these blocks of generated code!
  30.     //}}AFX_MSG_MAP
  31. END_MESSAGE_MAP()
  32.  
  33. /////////////////////////////////////////////////////////////////////////////
  34. // CBarDoc construction/destruction
  35.  
  36. CBarDoc::CBarDoc()
  37. {
  38.     CString settings("Settings");
  39.     
  40.     m_sData = AfxGetApp()->GetProfileString(settings,"Data","12345678");
  41.     m_sText = AfxGetApp()->GetProfileString(settings,"Text","HEX Technology");
  42.     m_iDisplayFlags = AfxGetApp()->GetProfileInt(settings,"DisplayFlags", (int) ( FLAG_CheckDigit | FLAG_ShowData));
  43.      m_sFontFace = AfxGetApp()->GetProfileString(settings,"FontFace","Arial");
  44.      m_bBold = AfxGetApp()->GetProfileInt(settings,"Bold", FALSE);
  45.     m_bItalic = AfxGetApp()->GetProfileInt(settings,"Italic", FALSE);
  46.     m_iRatio = AfxGetApp()->GetProfileInt(settings,"Ratio", 0);
  47.       m_iFontAdjust = AfxGetApp()->GetProfileInt(settings,"FontAdjust", 0);
  48.      m_iStyle = AfxGetApp()->GetProfileInt(settings,"Style", 11);  // EAN 8 for starters
  49.     m_iHeight = AfxGetApp()->GetProfileInt(settings,"Height", 21);  // 21 mm
  50.     m_iWidth = AfxGetApp()->GetProfileInt(settings,"Width", 31);  // 31 mm
  51.     m_cBarColor = RGB(0,0,0);                // black bars as normal
  52.     m_cBackgroundColor = RGB(255,255,128);  // light yellow     
  53.     
  54. }
  55.  
  56. CBarDoc::~CBarDoc()
  57.     CString settings("Settings");
  58.  
  59.     AfxGetApp()->WriteProfileString(settings,"Data",m_sData);
  60.     AfxGetApp()->WriteProfileString(settings,"Text",m_sText);
  61.     AfxGetApp()->WriteProfileInt(settings,"Bold", m_bBold);
  62.     AfxGetApp()->WriteProfileInt(settings,"DisplayFlags", m_iDisplayFlags);
  63.     AfxGetApp()->WriteProfileString(settings,"FontFace",m_sFontFace );
  64.      AfxGetApp()->WriteProfileInt(settings,"Italic", m_bItalic);
  65.     AfxGetApp()->WriteProfileInt(settings,"Ratio", m_iRatio );
  66.      AfxGetApp()->WriteProfileInt(settings,"FontAdjust", m_iFontAdjust );
  67.      AfxGetApp()->WriteProfileInt(settings,"Style", m_iStyle );
  68.     AfxGetApp()->WriteProfileInt(settings,"Height", m_iHeight);  
  69.     AfxGetApp()->WriteProfileInt(settings,"Width", m_iWidth ); 
  70.  
  71. }
  72.  
  73. BOOL CBarDoc::OnNewDocument()
  74. {
  75.     if (!CDocument::OnNewDocument())
  76.         return FALSE;
  77.  
  78.     // TODO: add reinitialization code here
  79.     // (SDI documents will reuse this document)
  80.  
  81.     return TRUE;
  82. }
  83.  
  84. /////////////////////////////////////////////////////////////////////////////
  85. // CBarDoc serialization
  86.  
  87. void CBarDoc::Serialize(CArchive& ar)
  88. {
  89.     if (ar.IsStoring())
  90.     {
  91.         ar << m_sData;
  92.         ar << m_sText;
  93.         ar << m_iDisplayFlags;
  94.         ar << m_sFontFace;
  95.         ar << (BYTE) m_bBold;
  96.         ar << (BYTE) m_bItalic;
  97.         ar << m_cBarColor;
  98.         ar << m_cBackgroundColor;  
  99.         ar << m_iStyle;  
  100.         ar << m_iRatio;
  101.         ar << m_iFontAdjust; 
  102.         ar << m_iWidth;
  103.         ar << m_iHeight;
  104.     }
  105.     else
  106.     {
  107.         ar >> m_sData;
  108.         ar >> m_sText;
  109.         ar >> m_iDisplayFlags;
  110.         ar >> m_sFontFace;            
  111.         BYTE b;
  112.         ar >> b; m_bBold = (BOOL) b;
  113.         ar >> b; m_bItalic = (BOOL) b;
  114.         ar >> m_cBarColor;
  115.         ar >> m_cBackgroundColor;  
  116.         ar >> m_iStyle;  
  117.         ar >> m_iRatio;
  118.         ar >> m_iFontAdjust;
  119.         ar >> m_iWidth;
  120.         ar >> m_iHeight;
  121.     }
  122. }
  123.  
  124. /////////////////////////////////////////////////////////////////////////////
  125. // CBarDoc diagnostics
  126.  
  127. #ifdef _DEBUG
  128. void CBarDoc::AssertValid() const
  129. {
  130.     CDocument::AssertValid();
  131. }
  132.  
  133. void CBarDoc::Dump(CDumpContext& dc) const
  134. {
  135.     CDocument::Dump(dc);
  136. }
  137. #endif //_DEBUG
  138.  
  139. /////////////////////////////////////////////////////////////////////////////
  140. // CBarDoc commands
  141.